﻿Imports TNCDAL

Public Class frmVoyageFilter
    Private dc As New TanNamChinhDataContext

    ''' <summary>
    ''' Gọi hàm khởi tạo này nếu muốn lấy các HBL của một File
    ''' </summary>
    ''' <param name="obj"></param>
    ''' <remarks></remarks>
    Public Sub New(ByVal query As IQueryable(Of tblVoyage))
        InitializeComponent()
        'Lưu thông tin File
        dataGridViewVoyage.DataSource = query
    End Sub

    Public ReadOnly Property SelectedVoyage() As tblVoyage
        Get
            Return _objVoyage
        End Get
    End Property

    Private Sub frmVoyageFilter_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private _objVoyage As tblVoyage
    Private Sub dataGridViewVoyage_CellDoubleClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dataGridViewVoyage.CellDoubleClick
        If dataGridViewVoyage.CurrentCell IsNot Nothing Then
            _objVoyage = dc.tblVoyages.SingleOrDefault(Function(p As tblVoyage) p.ID_Voyage = dataGridViewVoyage.Rows(dataGridViewVoyage.CurrentCell.RowIndex).Cells("ID_Voyage").Value)
            Me.Close()
        End If
    End Sub
End Class